using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SMWJamecl.BusinessEntities;

namespace SMWJamecl.Repository.Mapping
{
    public class VersionMap : EntityTypeConfiguration<Version>
    {
        public VersionMap()
        {
            // Primary Key
            this.HasKey(t => t.Id_Version);

            // Properties
            this.Property(t => t.Id_Version)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Desc_Version)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Version");
            this.Property(t => t.Id_Version).HasColumnName("Id_Version");
            this.Property(t => t.Desc_Version).HasColumnName("Desc_Version");
            this.Property(t => t.Id_Modelo).HasColumnName("Id_Modelo");

            // Relationships
            this.HasOptional(t => t.Modelo)
                .WithMany(t => t.Versions)
                .HasForeignKey(d => d.Id_Modelo);

        }
    }
}
